//test address
//https://code.google.com/codejam/contest/6224486/dashboard
#include <iostream>
#include <cstdlib>
#include <fstream>
#include <ctime>

using namespace std;

#define debug


int inv(int & n, string & s);

int main()
{
    #ifdef debug
    ifstream cin("E:\\git\\cp\\StandingOvation\\input.txt");
    ofstream cout("E:\\git\\cp\\StandingOvation\\output.txt");
    #endif

    int t, n;
    string s;
    cin >> t;
    //cout << t;
    for(int i = 1; i <= t; i++)
    {
        cin >> n >> s;
        cout << "Case #" << i << ": ";
        cout << inv(n, s) << endl;
    }
/*
    #ifdef debug
    cout << clock() / (double)CLOCKS_PER_SEC << endl;
    #endif
*/
    return 0;
}

int inv(int & n, string & s)
{
    int i = 1, ans = 0, k = 0;
    if(n > 0) ans = s[0] - '0';
    while(i <= n)
    {
        if(ans < i)
        {
            k += i - ans;
            ans += i - ans;
        }
        ans += s[i] - '0';
        i++;
    }
    return k;
}

